Skip to content

feat(trace): add advanced span filters - #2466

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi-feat-sdk-317-add-span-filters
Sep 11, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi-feat-sdk-317-add-span-filters

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

resolves https://linear.app/braintrustdata/issue/SDK-343/add-filters-on-traceget-spans-to-javascript-sdk

Add filters to Trace.getSpans() so callers can select spans by type, name, error state, partial metadata, and duration without fetching the whole trace and filtering it themselves.

const spans = await trace.getSpans({
  filters: {
    spanType: ["tool"],
    name: ["search", "lookup"],
    hasError: true,
    metadata: { model: "gpt-5" },
    duration: { min: 0.5, max: 10 },
  },
});

Combine filter dimensions with AND and match any value within each name or span-type list. Duration bounds are inclusive and measured in seconds. Keep the existing top-level spanType option supported.

Apply consistent filtering to buffered spans, complete trace caches, and BTQL queries. Validate metadata as cycle-free JSON data, check returned metadata candidates locally to avoid backend type coercion, and avoid caching partial filtered results as complete traces.

Add `filters` to `Trace.getSpans()` so callers can select spans by type,
name, error state, partial metadata, and duration without fetching the
whole trace and filtering it themselves.

```typescript
const spans = await trace.getSpans({
  filters: {
    spanType: ["tool"],
    name: ["search", "lookup"],
    hasError: true,
    metadata: { model: "gpt-5" },
    duration: { min: 0.5, max: 10 },
  },
});
```

Combine filter dimensions with AND and match any value within each name
or span-type list. Duration bounds are inclusive and measured in seconds.
Keep the existing top-level `spanType` option supported.

Apply consistent filtering to buffered spans, complete trace caches, and
BTQL queries. Validate metadata as cycle-free JSON data, check returned
metadata candidates locally to avoid backend type coercion, and avoid
caching partial filtered results as complete traces.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T18:37:52.015979Z 795643c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 4a79372 into main Sep 11, 2026
47 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi-feat-sdk-317-add-span-filters branch September 11, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants